/**
 * 
 */
package com.uobgroup.ews.uam.core.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.springframework.beans.factory.annotation.Configurable;

/**
 * @author phuongtran
 * 
 */
@Configurable
@Entity
@Table(name = "COMBINATIONACL")
public class CombinationACL extends BaseEntity implements SecurityGroupAware {

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "id")
   private Long id;

   @ManyToOne
   private CombinationMatrix combination;

   @ManyToOne
   private AccessControl accessControl;

   @OneToOne(cascade = CascadeType.PERSIST)
   private SecurityGroup securityGroup;

   public Long getId() {
      return id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public CombinationMatrix getCombination() {
      return combination;
   }

   public void setCombination(CombinationMatrix combination) {
      this.combination = combination;
   }

   public AccessControl getAccessControl() {
      return accessControl;
   }

   public void setAccessControl(AccessControl accessControl) {
      this.accessControl = accessControl;
   }

   public SecurityGroup getSecurityGroup() {
      return securityGroup;
   }

   public void setSecurityGroup(SecurityGroup securityGroup) {
      this.securityGroup = securityGroup;
   }

   @Override
   public String getSecurityGroupName() {
      return securityGroup == null ? null : securityGroup.getDisplayName();
   }

   @Override
   public String getParentGroupName() {
      return "combinationkey";
   }

}
